package com.businessportal.web.controllers.blog;

import com.businessportal.web.dataaccess.entities.BlogEntity;
import com.businessportal.web.dataaccess.entities.Login;
import com.businessportal.web.dataaccess.services.BlogEntityService;
import com.businessportal.web.dataaccess.services.UserService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;
import java.util.Set;

/**
 * Created by Vadim on 11/7/14.
 */
@WebServlet(urlPatterns = "/publicpages/blog_list.do")
public class BlogListViewerController extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        try {
            req.setCharacterEncoding("UTF-8");

            req.setAttribute("blogs", BlogEntityService.INSTANCE.getAllPublicBlogs());

        } catch(Exception e){
            req.setAttribute("errors", e.getMessage());
        }

        getServletContext().getRequestDispatcher("/publicpages/blog_list.jsp").forward(req, resp);

    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
    }
}
